<style>
    #billboy{
        font-size: 14px;
        width: 80%;
    }
    #userdetail{
        line-height: 36px;
        padding-left: 20px;
        padding-bottom: 10px;
        font-size: 16px;
    }
    #userdetail input{
        width: 80%;
        height: 20px;
        font-size: 16px;
    }
    #bf{
        background-color: #eee;
        text-align: right;
        width: 15%;
        height: 50px;
    }
    #cf{
        width: 35%;
    }
</style>
<?php
if($this->ma == 1){
    echo '<script language="javascript" type="text/javascript">alert("信息发送成功！");location.href = "/admini/manageuser/email/"; </script>';
}else if($this->ma == 2){
    echo '<script language="javascript" type="text/javascript">alert("信息发送失败，请重新发布！");</script>';
}
?>
<div id="billboy">
    <div id='userdetail'>
        发布邮件
        <form action="" method="post">
        <table width="100%" border="1" cellpadding="0" cellspacing="0">  
            <tr>
              <td id='bf'>邮箱：</td>
              <td id='cf' valign="middle">&nbsp;&nbsp;<input type="text" name="username" id="username" value="<?php echo $this->emailall?$this->emailall->recipients:"";?>"/></td>
              <td id='bf'>仓库号：</td>
              <td id='cf' valign="middle">&nbsp;&nbsp;<input type="text" name="storeno" id="storeno"  value=""/></td>
            </tr>
            <tr>
              <td id='bf'>标题：</td>
              <td id='cf' colspan="3" valign="middle">&nbsp;&nbsp;<input type="text" name="title" id="title" value="<?php echo $this->emailall?$this->emailall->title:"";?>"/></td>
            </tr>
            <tr>
              <td id='bf' style="height:250px;">内容：</td>
              <td id='cf' colspan="3" valign="middle">&nbsp;&nbsp;<textarea name="message" id="message"  cols="99" rows="12" style="font-size:16px;resize:none;"><?php echo $this->emailall?$this->emailall->content:"";?></textarea></td>
            </tr>
            <tr>
                <td id='cf' colspan="4" align="center">
                    <input type="submit" id="submit" name="submit" value="发送邮件" style="background-color: #1668A4;width: 80px;height: 36px;color: white;font-size: 16px;border-radius:8px;" />&nbsp;&nbsp;</td>
            </tr>
          </table>
          </form>
    </div>
</div>
<script type="text/javascript">
    var isuser = true;
    $('#username').blur(function(){
        var username = $(this).val();
        if(username != ''){
            $.post('/admini/manageuser/bystoreno', {'username':username}, function(data){
                if(data.id != ""){
                    $('#storeno').attr('value',data.storeno);
                    $('#userId').attr('value',data.id);
                    isuser = true;
                }else{
                    isuser = false;
                    $('#storeno').attr('value','');
                    $('#userId').attr('value','');
                }
            }, 'json');
            return false;
        }else{
            $('#storeno').attr('value','');
            $('#userId').attr('value','');
            return false;
        }
    });
    $('#storeno').blur(function(){
        var storeno = $(this).val();
        if(storeno != ''){
            $.post('/admini/manageuser/byusername', {'storeno':storeno}, function(data){
                if(data.id != ""){
                    $('#username').attr('value',data.email);
                    $('#userId').attr('value',data.id);
                    isuser = true;
                }else{
                    alert("没有该用户，请重新输入所属用户！");
                    isuser = false;
                    $('#username').attr('value','');
                    $('#storeno').attr('value','');
                    $('#userId').attr('value','');
                }
            }, 'json');
        }else{
            $('#username').attr('value','');
            $('#userId').attr('value','');
        }
    });
    $('#submit').click(function(){
        var storeno = $('#storeno').val();
        var title = $('#title').val();
        var message = $('#message').val();
        if(title == ''){
            alert("信息标题不能为空！");
            return false;
        }else if(message == ''){
            alert("信息内容不能为空！");
            return false;
        }
    });
</script>